hysop.operator.min_max module

@file min_max.py MinMaxFieldStatistics: compute min(f), max(f) and/or max(|f|) for a given field f. MinMaxDerivativeStatistics: compute min(d^k(Fi)/dXj^k), max(d^kFi/dXj^k) and/or max(|dFi/dXj|)

for a given field, component, direction and order.

MinMaxGradientStatistics: compute min(dFi/dXj), max(dFi/dXj) and/or max(|dFi/dXj|)

for a given field, up to all components in all directions.

class hysop.operator.min_max.MinMaxDerivativeStatistics(F, dF=None, A=None, derivative=None, direction=None, Fmin=None, Fmax=None, Finf=None, coeffs=None, all_quiet=False, name=None, pbasename=None, ppbasename=None, variables=None, implementation=None, base_kwds=None, **kwds)[source]

Bases: ComputationalGraphNodeFrontend

Operator frontend to compute min and max statistics on a specific derivative of a scalar field, without keeping its output.

Initialize a MinMaxDerivativeStatistics operator frontend. Available operator backends are PYTHON and OPENCL.

MinMaxDerivativeStatistics can compute some commonly required Field derivative statistics:

Fmin: min value of a derivative of the field. Fmax: max value of a derivative of the field. Finf: max value of the absolute value of a

derivative of the field (computed using Fmin and Fmax).

First compute the derivative of a scalar field F in a given direction at a given order and on a given backend out of place in scalar field dF The derivative is then possibly scaled by another field/parameter/value A.

After the scaled derivative has been computed, compute user requested statistics (min and max values) on this new field and scale those statistics by other scaling parameters stored in coeffs.

  1. Compute derivative

    dF[k] = alpha * d^n(F[i])/dXj**n

  2. Compute statistics

    Fmin = Smin * min(dF) Fmax = Smax * max(dF) Finf = Sinf * max(|Fmin|, |Fmax|)

where F is an input field

dF is an output field (by default a temporary field). n = derivative order > 0 alpha = A, where A is a Field, a Parameter or a scalar. Fmin = created or supplied TensorParameter. Fmax = created or supplied TensorParameter. Finf = created or supplied TensorParameter. Smin = coeffs[‘Fmin’] Smax = coeffs[‘Fmax’] Sinf = coeffs[‘Finf’]

Statistics are only computed if explicitely requested by user,

unless required to compute another user-required statistic, see Notes.

Parameters:
  • F (hysop.field.continuous_field.Field) – Continuous field as input.

  • dF (hysop.field.continuous_field.Field, optional) – Continuous field to be written. Some backend may allow inplace differentiation. By default a temporary scalar field is created, which means that the computation of the derivative may be discarded after this operator has been applied because of temporary buffer sharing between operators.

  • A (numerical value, ScalarParameter or Field, optional) – Scaling field/parameter/value for convenience. Defaults to no scaling.

  • derivative (int, optional) – Which derivative to generate. Defaults to 1.

  • direction (int, optional) – Directions in which to take the derivative. Defaults to 0.

  • F... (TensorParameter) – The output parameters that will contain the statistics. At least one statistic should be specified (either by boolean or TensorParameter). TensorParameters should be of shape (1,). If set to True, the TensorParameter will be generated automatically. Autogenerated TensorParameters that are not required by the user (ie. left to None or False during __init__) are, if required, generated but set to be quiet. Autogenerated parameters can be retrieved using the ‘Fmin’, ‘Fmax’ and ‘Finf’ attributes.

  • all_quiet (bool) – Set all autogenerated TensorParameter to be quiet.

  • coeffs (dict of array like of coefficients, optional) – Optional scaling of the statistics. Scaling factor should be a scalar or an array-like of scalars for each components. If not given, defaults to 1 for all statistics.

  • name (str, optional) – Name of this operator.

  • pbasename (str, optional) – Parameters basename for created parameters. Defaults to field.name.

  • ppbasename (str, optional) – Parameters pretty basename for created parameters. Defaults to pbasename.

  • variables (dict, optional) – Dictionary of fields as keys and topologies as values.

  • implementation (hysop.constants.Implementation, optional) – Specify underlying backend implementation. Target implementation, should be contained in available_implementations(). If None, implementation will be set to default_implementation().

  • base_kwds (dict, optional) – Base class keyword arguments as a dictionnary.

  • kwds – Extra keyword arguments passed towards operator backend implementation.

  • Attributes

  • -----------

  • F... – All generated tensor parameters. Unused statistics are set to None.

Notes

About statistics:
Finf requires to compute Fmin and Fmax and will have value:

Finf = Sinf * max( abs(Smin*Fmin), abs(Smax*Fmax))

where Sinf, Smin and Smax are the scaling coefficients defined in coeffs.

classmethod default_implementation()[source]

Return the default Implementation, should be compatible with available_implementations.

classmethod implementations()[source]

Should return all implementations as a dictionnary. Keys are Implementation instances and values are either ComputationalGraphNode or ComputationalGraphNodeGenerator.

class hysop.operator.min_max.MinMaxFieldStatistics(field, components=None, coeffs=None, Fmin=None, Fmax=None, Finf=None, all_quiet=False, name=None, pbasename=None, ppbasename=None, variables=None, implementation=None, base_kwds=None, **kwds)[source]

Bases: ComputationalGraphNodeFrontend

Operator frontend to compute min and max statistics on the specific field.

Initialize a MinMaxFieldStatistics operator frontend. Available operator backends are PYTHON and OPENCL.

MinMaxFieldStatistics can compute some commonly required Field statistics:

Fmin: component-wise min values of the field. Fmax: component-wise max values of the field. Finf: component-wise max values of the absolute value of the field (computed using

Fmin and Fmax).

All statistics are only computed if explicitely requested by user,

unless required to compute another user-required statistic, see Notes.

All statistics may also be additionaly scaled by a coefficient.

Compute vectorized statistics:

Fmin = Smin * min(F[components]) Fmax = Smax * max(F[components]) Finf = Sinf * max(|Fmin|, |Fmax|)

where F is an input field

Fmin = created or supplied TensorParameter. Fmax = created or supplied TensorParameter. Finf = created or supplied TensorParameter. Smin = coeffs[‘Fmin’] Smax = coeffs[‘Fmax’] Sinf = coeffs[‘Finf’]

Parameters:
  • field (Field) – The continuous field on which the statistics will be computed.

  • components (array like of ints, optional) – The components on which the statistics are computed, defaults to all components.

  • coeffs (dict of array like of coefficients, optional) – Optional scaling of the statistics. Scaling factor should be a scalar or an array-like of scalars for each components. If not given, defaults to 1 for all statistics.

  • F... (TensorParameter) – At least one statistic should be specified (either by boolean or TensorParameter). TensorParameters should be of shape (nb_components,), see Notes. If set to True, the TensorParameter will be generated automatically. Autogenerated TensorParameters that are not required by the user (ie. left to None or False during __init__) are, if required, generated but set to be quiet.

  • all_quiet (bool) – Set all autogenerated TensorParameter to be quiet.

  • name (str, optional) – Name of this operator.

  • pbasename (str, optional) – Parameters basename for created parameters. Defaults to field.name.

  • ppbasename (str, optional) – Parameters pretty basename for created parameters. Defaults to pbasename.

  • variables (dict, optional) – Dictionary of fields as keys and topologies as values.

  • implementation (hysop.constants.Implementation, optional) – Specify underlying backend implementation. Target implementation, should be contained in available_implementations(). If None, implementation will be set to default_implementation().

  • base_kwds (dict, optional) – Base class keyword arguments as a dictionnary.

  • kwds – Extra keyword arguments passed towards operator backend implementation.

  • Attributes

  • -----------

  • F... – All generated tensor parameters. Unused statistics are set to None.

Notes

nb_components = min(field.nb_components, len(components)).

About statistics:
Finf requires to compute Fmin and Fmax and will have value:

Finf = Sinf * max( abs(Smin*Fmin), abs(Smax*Fmax))

where Sinf, Smin and Smax are the scaling coefficients defined in coeffs.

classmethod default_implementation()[source]

Return the default Implementation, should be compatible with available_implementations.

classmethod implementations()[source]

Should return all implementations as a dictionnary. Keys are Implementation instances and values are either ComputationalGraphNode or ComputationalGraphNodeGenerator.

class hysop.operator.min_max.MinMaxFiniteDifferencesDerivativeStatistics(F, dF=None, A=None, derivative=None, direction=None, Fmin=None, Fmax=None, Finf=None, coeffs=None, all_quiet=False, name=None, pbasename=None, ppbasename=None, variables=None, implementation=None, base_kwds=None, **kwds)[source]

Bases: MinMaxDerivativeStatistics

Operator frontend to compute min and max statistics on a specific derivative of a scalar field using finite differences.

Initialize a MinMaxDerivativeStatistics operator frontend. Available operator backends are PYTHON and OPENCL.

MinMaxDerivativeStatistics can compute some commonly required Field derivative statistics:

Fmin: min value of a derivative of the field. Fmax: max value of a derivative of the field. Finf: max value of the absolute value of a

derivative of the field (computed using Fmin and Fmax).

First compute the derivative of a scalar field F in a given direction at a given order and on a given backend out of place in scalar field dF The derivative is then possibly scaled by another field/parameter/value A.

After the scaled derivative has been computed, compute user requested statistics (min and max values) on this new field and scale those statistics by other scaling parameters stored in coeffs.

  1. Compute derivative

    dF[k] = alpha * d^n(F[i])/dXj**n

  2. Compute statistics

    Fmin = Smin * min(dF) Fmax = Smax * max(dF) Finf = Sinf * max(|Fmin|, |Fmax|)

where F is an input field

dF is an output field (by default a temporary field). n = derivative order > 0 alpha = A, where A is a Field, a Parameter or a scalar. Fmin = created or supplied TensorParameter. Fmax = created or supplied TensorParameter. Finf = created or supplied TensorParameter. Smin = coeffs[‘Fmin’] Smax = coeffs[‘Fmax’] Sinf = coeffs[‘Finf’]

Statistics are only computed if explicitely requested by user,

unless required to compute another user-required statistic, see Notes.

Parameters:
  • F (hysop.field.continuous_field.Field) – Continuous field as input.

  • dF (hysop.field.continuous_field.Field, optional) – Continuous field to be written. Some backend may allow inplace differentiation. By default a temporary scalar field is created, which means that the computation of the derivative may be discarded after this operator has been applied because of temporary buffer sharing between operators.

  • A (numerical value, ScalarParameter or Field, optional) – Scaling field/parameter/value for convenience. Defaults to no scaling.

  • derivative (int, optional) – Which derivative to generate. Defaults to 1.

  • direction (int, optional) – Directions in which to take the derivative. Defaults to 0.

  • F... (TensorParameter) – The output parameters that will contain the statistics. At least one statistic should be specified (either by boolean or TensorParameter). TensorParameters should be of shape (1,). If set to True, the TensorParameter will be generated automatically. Autogenerated TensorParameters that are not required by the user (ie. left to None or False during __init__) are, if required, generated but set to be quiet. Autogenerated parameters can be retrieved using the ‘Fmin’, ‘Fmax’ and ‘Finf’ attributes.

  • all_quiet (bool) – Set all autogenerated TensorParameter to be quiet.

  • coeffs (dict of array like of coefficients, optional) – Optional scaling of the statistics. Scaling factor should be a scalar or an array-like of scalars for each components. If not given, defaults to 1 for all statistics.

  • name (str, optional) – Name of this operator.

  • pbasename (str, optional) – Parameters basename for created parameters. Defaults to field.name.

  • ppbasename (str, optional) – Parameters pretty basename for created parameters. Defaults to pbasename.

  • variables (dict, optional) – Dictionary of fields as keys and topologies as values.

  • implementation (hysop.constants.Implementation, optional) – Specify underlying backend implementation. Target implementation, should be contained in available_implementations(). If None, implementation will be set to default_implementation().

  • base_kwds (dict, optional) – Base class keyword arguments as a dictionnary.

  • kwds – Extra keyword arguments passed towards operator backend implementation.

  • Attributes

  • -----------

  • F... – All generated tensor parameters. Unused statistics are set to None.

Notes

About statistics:
Finf requires to compute Fmin and Fmax and will have value:

Finf = Sinf * max( abs(Smin*Fmin), abs(Smax*Fmax))

where Sinf, Smin and Smax are the scaling coefficients defined in coeffs.

classmethod default_implementation()[source]

Return the default Implementation, should be compatible with available_implementations.

classmethod implementations()[source]

Should return all implementations as a dictionnary. Keys are Implementation instances and values are either ComputationalGraphNode or ComputationalGraphNodeGenerator.

class hysop.operator.min_max.MinMaxSpectralDerivativeStatistics(F, dF=None, A=None, derivative=None, direction=None, Fmin=None, Fmax=None, Finf=None, coeffs=None, all_quiet=False, name=None, pbasename=None, ppbasename=None, variables=None, implementation=None, base_kwds=None, **kwds)[source]

Bases: MinMaxDerivativeStatistics

Operator frontend to compute min and max statistics on a specific derivative of a scalar field using the spectral method.

Initialize a MinMaxDerivativeStatistics operator frontend. Available operator backends are PYTHON and OPENCL.

MinMaxDerivativeStatistics can compute some commonly required Field derivative statistics:

Fmin: min value of a derivative of the field. Fmax: max value of a derivative of the field. Finf: max value of the absolute value of a

derivative of the field (computed using Fmin and Fmax).

First compute the derivative of a scalar field F in a given direction at a given order and on a given backend out of place in scalar field dF The derivative is then possibly scaled by another field/parameter/value A.

After the scaled derivative has been computed, compute user requested statistics (min and max values) on this new field and scale those statistics by other scaling parameters stored in coeffs.

  1. Compute derivative

    dF[k] = alpha * d^n(F[i])/dXj**n

  2. Compute statistics

    Fmin = Smin * min(dF) Fmax = Smax * max(dF) Finf = Sinf * max(|Fmin|, |Fmax|)

where F is an input field

dF is an output field (by default a temporary field). n = derivative order > 0 alpha = A, where A is a Field, a Parameter or a scalar. Fmin = created or supplied TensorParameter. Fmax = created or supplied TensorParameter. Finf = created or supplied TensorParameter. Smin = coeffs[‘Fmin’] Smax = coeffs[‘Fmax’] Sinf = coeffs[‘Finf’]

Statistics are only computed if explicitely requested by user,

unless required to compute another user-required statistic, see Notes.

Parameters:
  • F (hysop.field.continuous_field.Field) – Continuous field as input.

  • dF (hysop.field.continuous_field.Field, optional) – Continuous field to be written. Some backend may allow inplace differentiation. By default a temporary scalar field is created, which means that the computation of the derivative may be discarded after this operator has been applied because of temporary buffer sharing between operators.

  • A (numerical value, ScalarParameter or Field, optional) – Scaling field/parameter/value for convenience. Defaults to no scaling.

  • derivative (int, optional) – Which derivative to generate. Defaults to 1.

  • direction (int, optional) – Directions in which to take the derivative. Defaults to 0.

  • F... (TensorParameter) – The output parameters that will contain the statistics. At least one statistic should be specified (either by boolean or TensorParameter). TensorParameters should be of shape (1,). If set to True, the TensorParameter will be generated automatically. Autogenerated TensorParameters that are not required by the user (ie. left to None or False during __init__) are, if required, generated but set to be quiet. Autogenerated parameters can be retrieved using the ‘Fmin’, ‘Fmax’ and ‘Finf’ attributes.

  • all_quiet (bool) – Set all autogenerated TensorParameter to be quiet.

  • coeffs (dict of array like of coefficients, optional) – Optional scaling of the statistics. Scaling factor should be a scalar or an array-like of scalars for each components. If not given, defaults to 1 for all statistics.

  • name (str, optional) – Name of this operator.

  • pbasename (str, optional) – Parameters basename for created parameters. Defaults to field.name.

  • ppbasename (str, optional) – Parameters pretty basename for created parameters. Defaults to pbasename.

  • variables (dict, optional) – Dictionary of fields as keys and topologies as values.

  • implementation (hysop.constants.Implementation, optional) – Specify underlying backend implementation. Target implementation, should be contained in available_implementations(). If None, implementation will be set to default_implementation().

  • base_kwds (dict, optional) – Base class keyword arguments as a dictionnary.

  • kwds – Extra keyword arguments passed towards operator backend implementation.

  • Attributes

  • -----------

  • F... – All generated tensor parameters. Unused statistics are set to None.

Notes

About statistics:
Finf requires to compute Fmin and Fmax and will have value:

Finf = Sinf * max( abs(Smin*Fmin), abs(Smax*Fmax))

where Sinf, Smin and Smax are the scaling coefficients defined in coeffs.

classmethod default_implementation()[source]

Return the default Implementation, should be compatible with available_implementations.

classmethod implementations()[source]

Should return all implementations as a dictionnary. Keys are Implementation instances and values are either ComputationalGraphNode or ComputationalGraphNodeGenerator.